package tedu.boot31.mapper;

import org.apache.ibatis.annotations.*;
import tedu.boot31.entity.Product;

import java.util.List;

@Mapper
public interface ProductMapper {

    @Insert("insert into product values(null,#{title},#{price},#{saleCount})")
    void insert(Product product);

    @Select("select * from product")
    @Result(column = "sale_count",property = "saleCount")
    List<Product> selectAllProduct();

    @Delete("delete from product where id=#{id}")
    void deleteById(Integer id);

    @Update("update product set title=#{title},price=#{price},sale_count=#{saleCount} where id=#{id}")
    void updateById(Product product);
}
